package com.example.demo.ThreadPool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author shkstart
 * @date 2019/6/10- 16:16
 */
public class TestDemo03 {
    public static void main(String[] args) {
        //01创建可定时线程池
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
        for (int i = 0; i < 10; i++) {
            final int temp = i;
            scheduledExecutorService.schedule(new Runnable() {
                @Override
                public void run() {
                    System.out.println("i" + temp);
                }
            }, 3, TimeUnit.SECONDS);
        }

    }
}
